﻿using FrameworkCore.Modules.Startups;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace Infrastructure.Startups;

/// <summary>
/// 跨域配置
/// </summary>
public partial class NetModulerCorsStartup : INetModulerStartup
{
    /// <summary>
    /// 添加和配置任何中间件
    /// </summary>
    /// <param name="services">服务描述符集合</param>
    /// <param name="configuration">应用程序的配置</param>
    public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
    {
    }

    /// <summary>
    /// 配置已添加中间件的使用方式
    /// </summary>
    /// <param name="application">用于配置应用程序请求管道的构建器</param>
    public void Configure(IApplicationBuilder application)
    {
        application.UseCors(options =>
        {
            options.AllowAnyOrigin()
                   .AllowAnyHeader()
                   .AllowAnyMethod();
        });
    }

    /// <summary>
    /// 获取此启动配置实现的顺序
    /// </summary>
    public int Order => 100; 
}